package bdqn.t09.controller;

import bdqn.t09.pojo.AsUser;
import bdqn.t09.service.AsUserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Controller
public class UserController {

    @Resource
    private AsUserService asUserService;

    @RequestMapping(value ={"/"},method = RequestMethod.GET)
    public String goUserLogin(){
        return  "login";
    }

    @RequestMapping("/login")
    @ResponseBody
    public String goUserLogin(String usercode,String userpassword,Model model,HttpSession session){
        AsUser user = asUserService.login(usercode,userpassword);
        if(user != null){
            session.setAttribute("loginUser",user);
            return "true";
        }
        return "false";
    }
    //登录成功后跳转
    @RequestMapping("/agentManagement")
    public String goAgentNanagement(){
        return  "agentManagement";
    }

    @RequestMapping("/agenZiLianJie")
    public String goagenZiLianJie(){
        return  "agenZiLianJie";
    }

}
